﻿/*
    Using loops write a program that converts a binary integer number to its decimal form.
    The input is entered as string. The output should be a variable of type long.
    Do not use the built-in .NET functionality.
 */


using System;
class BinaryToDecimal
{
    static void Main()
    {
        string binNumber;
        long decNumber = 0;

        Console.WriteLine("Enter binary number: ");
        binNumber = Console.ReadLine();

        for (int i = 0; i < binNumber.Length; i++)
        {
            if (binNumber[binNumber.Length - i - 1] == '0') continue;
            decNumber += (int)Math.Pow(2, i);
        }
        Console.WriteLine(decNumber);
    }
}
